package com.example.makerspace.controller.maker;

import com.example.makerspace.dto.Result;
import com.example.makerspace.dto.maker.AreaBaseDTO;
import com.example.makerspace.service.AreaService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

@Controller
@ResponseBody
@RequestMapping("/api/area")
public class AreaController {

    @Autowired
    private AreaService areaService;

    @PostMapping("/create")
    public Result create(@RequestBody AreaBaseDTO areaBaseDTO) {
        return areaService.create(areaBaseDTO);
    }

    @GetMapping("/query")
    public Result query(){
        return areaService.query();
    }

    @PostMapping("/delete")
    public Result delete(@RequestBody AreaBaseDTO areaBaseDTO){
        return areaService.delete(areaBaseDTO.getId());
    }

    @PostMapping("/update")
    public Result update(@RequestBody AreaBaseDTO areaBaseDTO){
        return areaService.update(areaBaseDTO);
    }
}
